
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 07/18/2012 01:11:56
-- Generated from EDMX file: D:\XQ2012\SourceCode\Remember\remcloud\RememberLib\Remember.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Remember];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[CategoryList]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CategoryList];
GO
IF OBJECT_ID(N'[dbo].[ItemCategoryLink]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ItemCategoryLink];
GO
IF OBJECT_ID(N'[dbo].[RemeberToday]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RemeberToday];
GO
IF OBJECT_ID(N'[dbo].[RememberHistory]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RememberHistory];
GO
IF OBJECT_ID(N'[dbo].[RememberItem]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RememberItem];
GO
IF OBJECT_ID(N'[dbo].[RememberPlan]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RememberPlan];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'RememberPlan'
CREATE TABLE [dbo].[RememberPlan] (
    [PlanID] int IDENTITY(1,1) NOT NULL,
    [PlanDesc] nvarchar(max)  NOT NULL,
    [ShowedDate] nvarchar(max)  NOT NULL,
    [IsShowed] nvarchar(max)  NOT NULL,
    [PlanDate] nvarchar(max)  NOT NULL,
    [ItemID] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'ItemCategoryLink'
CREATE TABLE [dbo].[ItemCategoryLink] (
    [ItemCategoryLinkID] int IDENTITY(1,1) NOT NULL,
    [ItemID] int  NOT NULL,
    [CategoryID] int  NOT NULL
);
GO

-- Creating table 'RemeberToday'
CREATE TABLE [dbo].[RemeberToday] (
    [TodayID] int IDENTITY(1,1) NOT NULL,
    [ItemID] int  NOT NULL,
    [TodayDate] nvarchar(max)  NULL,
    [CheckResult] nvarchar(max)  NULL,
    [LoginID] nvarchar(max)  NULL,
    [CheckType] nvarchar(max)  NULL
);
GO

-- Creating table 'RememberHistory'
CREATE TABLE [dbo].[RememberHistory] (
    [HistoryID] int IDENTITY(1,1) NOT NULL,
    [ItemID] int  NOT NULL,
    [ItemOrder] int  NOT NULL,
    [Difficulty] int  NOT NULL,
    [Importance] int  NOT NULL,
    [ShowFlow] nvarchar(50)  NULL,
    [LoginID] nvarchar(50)  NULL,
    [StartDate] datetime  NULL,
    [StartResult] int  NOT NULL,
    [LastDate] datetime  NULL,
    [LastResult] int  NOT NULL,
    [NextDate] datetime  NULL,
    [StopDate] datetime  NULL,
    [IsActivted] bit  NOT NULL,
    [CurveIndex] int  NOT NULL,
    [RepeatCount] int  NOT NULL,
    [ResultA] int  NOT NULL,
    [ResultB] int  NOT NULL,
    [ResultC] int  NOT NULL,
    [ResultD] int  NOT NULL
);
GO

-- Creating table 'CategoryList'
CREATE TABLE [dbo].[CategoryList] (
    [CategoryID] int IDENTITY(1,1) NOT NULL,
    [CategoryName] nvarchar(max)  NOT NULL,
    [CategoryDesc] nvarchar(max)  NULL,
    [ParentID] int  NULL,
    [CategoryLevel] int  NULL,
    [CategoryIndex] int  NULL,
    [ItemTotal] int  NULL,
    [FrequentlyIndex] int  NULL
);
GO

-- Creating table 'RememberItem'
CREATE TABLE [dbo].[RememberItem] (
    [ItemID] int IDENTITY(1,1) NOT NULL,
    [ItemFlag] int  NULL,
    [ItemOrder] int  NOT NULL,
    [ItemName] nvarchar(50)  NULL,
    [ItemType] nvarchar(max)  NULL,
    [ItemQuestion] nvarchar(max)  NOT NULL,
    [ItemAnswer] nvarchar(max)  NOT NULL,
    [ItemPicture] nvarchar(max)  NULL,
    [ItemSound] nvarchar(max)  NULL,
    [ItemVideo] nvarchar(max)  NULL,
    [ItemDesc] nvarchar(max)  NULL,
    [ItemRelation] nvarchar(max)  NULL,
    [ItemSource] nvarchar(max)  NULL
);
GO

-- Creating table 'Config'
CREATE TABLE [dbo].[Config] (
    [ConfigID] int IDENTITY(1,1) NOT NULL,
    [ConfigName] nvarchar(max)  NOT NULL,
    [ConfigValue] nvarchar(max)  NOT NULL,
    [ConfigValueType] nvarchar(max)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [PlanID] in table 'RememberPlan'
ALTER TABLE [dbo].[RememberPlan]
ADD CONSTRAINT [PK_RememberPlan]
    PRIMARY KEY CLUSTERED ([PlanID] ASC);
GO

-- Creating primary key on [ItemCategoryLinkID] in table 'ItemCategoryLink'
ALTER TABLE [dbo].[ItemCategoryLink]
ADD CONSTRAINT [PK_ItemCategoryLink]
    PRIMARY KEY CLUSTERED ([ItemCategoryLinkID] ASC);
GO

-- Creating primary key on [TodayID] in table 'RemeberToday'
ALTER TABLE [dbo].[RemeberToday]
ADD CONSTRAINT [PK_RemeberToday]
    PRIMARY KEY CLUSTERED ([TodayID] ASC);
GO

-- Creating primary key on [HistoryID] in table 'RememberHistory'
ALTER TABLE [dbo].[RememberHistory]
ADD CONSTRAINT [PK_RememberHistory]
    PRIMARY KEY CLUSTERED ([HistoryID] ASC);
GO

-- Creating primary key on [CategoryID] in table 'CategoryList'
ALTER TABLE [dbo].[CategoryList]
ADD CONSTRAINT [PK_CategoryList]
    PRIMARY KEY CLUSTERED ([CategoryID] ASC);
GO

-- Creating primary key on [ItemID] in table 'RememberItem'
ALTER TABLE [dbo].[RememberItem]
ADD CONSTRAINT [PK_RememberItem]
    PRIMARY KEY CLUSTERED ([ItemID] ASC);
GO

-- Creating primary key on [ConfigID] in table 'Config'
ALTER TABLE [dbo].[Config]
ADD CONSTRAINT [PK_Config]
    PRIMARY KEY CLUSTERED ([ConfigID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------